/**
 *
 */
package uk.co.hs.web.controller.admin;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import uk.co.hs.domain.web.WebForwarding;
import uk.co.hs.service.admin.interfaces.WebForwardingServiceInterface;
import uk.co.hs.web.interceptor.TabsAccessibilityInterceptor;

/**
 * ForwardingController.
 */
@Controller("hs_forwardingController")
@RequestMapping("/" + TabsAccessibilityInterceptor.FORWARDING_URL)
public class ForwardingController
{
  @Resource
  private WebForwardingServiceInterface mWebForwardingService;

  @RequestMapping(method = RequestMethod.GET)
  protected ModelAndView formBackingObject(HttpServletRequest aRequest,
                                           HttpServletResponse aResponse) throws Exception
  {
    WebForwarding wf = mWebForwardingService.getWebForwarding(SecurityContextHolder.getContext().getAuthentication().getName());
    aRequest.setAttribute("URL", wf.getWebUrl().getUrl());
    return new ModelAndView("hs_Forwarding");
  }
}
